﻿#region Imports
using System;
using System.Windows.Forms;
#endregion

namespace ExpenseMgrUtil
{
    public partial class frmResetInfo : Form
    {
        #region Declarations
        int tickCounter = 0;
        #endregion

        #region Properties
        public int ResetTime { get; set; }
        #endregion

        #region Constructors
        public frmResetInfo(int resetTime)
        {
            InitializeComponent();
            this.ResetTime = resetTime;
        }
        #endregion

        #region Destructors
        ~frmResetInfo()
        {
            this.Dispose();
        }
        #endregion

        #region Events
        private void frmResetInfo_Load(object sender, EventArgs e)
        {
            RefreshInfo();
            tmrReset.Start();
        }

        private void tmrReset_Tick(object sender, EventArgs e)
        {
            RefreshInfo();
            if (tickCounter > ResetTime + 1) { tmrReset.Stop(); Application.Restart(); }
        }
        #endregion

        #region Methods
        private void RefreshInfo()
        {
            lblResetInfo.Text = "Restarting in " + (ResetTime - tickCounter++) + "......";
        }
        #endregion
    }
}
